package org.mat.sample.controller;

import org.mat.framework.lang.dto.MatApiResponse;
import org.mat.sample.dto.DispatchRequest;
import org.mat.sample.entity.Order;
import org.mat.sample.service.LogisticsService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/logistics")
public class LogisticsController {

    private final LogisticsService logisticsService;

    public LogisticsController(LogisticsService logisticsService) {
        this.logisticsService = logisticsService;
    }

    @PostMapping("/dispatch")
    public MatApiResponse<String > batchDispatch(@RequestBody DispatchRequest request) {
        logisticsService.batchDispatch(request);
        return MatApiResponse.success("派单成功");
    }

    @GetMapping("/pending")
    public MatApiResponse<List<Order>> getPendingOrders(
            @RequestParam String centerId) {
        List<Order> orders = logisticsService.queryPendingOrders(centerId);
        return MatApiResponse.success(orders);
    }
}